package suanfa;

import org.apache.commons.lang3.StringUtils;

/**
 * 字符串反转
 */
public class StringReverse {
    public static void main(String[] args) {
        String str = "abc";
        System.out.println(reverseString(str));
    }

    public static String reverseString(String s){
        if (StringUtils.isBlank(s) || s.length() <=1){
            return s;
        }
        char[] chars = s.toCharArray();
        int left = 0,right = chars.length -1;
        while (left <right){
            char temp = chars[left];
            chars[left++] = chars[right];
            chars[right--] = temp;
        }
        return new String(chars);
    }

}
